<!-- 修改密码页面 【弹出层】 -->
<link rel="stylesheet" href="{_ADMIN_STATIC_}/buttons/button.css">
<link rel="stylesheet" href="{_ADMIN_STATIC_}/lib/bootstrap/css/bootstrap.min.css">

<style>
    #edit_password {
        position: relative;
        width: 100%;
        height: 100%;
        text-align: center;
    }

    #up {
        position: absolute;
        width: 100%;
        text-align: center;
    }

    #down {
        position: absolute;
        bottom: 10;
        width: 100%;
        height: 40px;
    }

    table{
        font-size: 16px;
    }
    #table>tr{
        background-color: black;
    }
</style>

<div id="edit_password">
    <div id="up">
        <table id="table" class="table">
            <tr>
                <td>账号</td>
                <td>
                    <input type="text" id="account" placeholder="请输入用户账号">
                </td>
                <td style="color:#F00;">*必填</td>
            </tr>
            <tr>
                <td>用户姓名</td>
                <td>
                    <input type="text" id="name" placeholder="请输入用户姓名">
                </td>
                <td style="color:#F00;">*必填</td>
            </tr>
            <tr>
                <td>默认密码</td>
                <td>
                    <h2>123456</h2>
                </td>
                <td style="color:#F00;"></td>
            </tr>
        </table>
    </div>

    <div id="down">
        <button class="button button-raised button-primary button-pill" onclick="save()">保存</button>
        <button class="button button-raised button-primary button-pill" onclick="back()">返回</button>
    </div>

</div>

<script src="{_ADMIN_STATIC_}/lib/jquery/jquery.js"></script>
<script src="{_ADMIN_STATIC_}/lib/layer/layer.js"></script>
<script>

    // 修改密码按钮
    function save() {

        var account = $('#account').val().trim();
        var name = $('#name').val().trim();
        if(account.length<4){
            return layer.msg('用户账号长度不少于4位', { icon: 2, time: 900 });
        }
        if(name.length<2){
            return layer.msg('用户昵称长度不少于2位', { icon: 2, time: 900 });
        }


        $.ajax({
            url: "{:url('User/user_add')}",
            data: {
                'account': account,
                'name': name,
            },
            type: "POST",
            dataType: "JSON",
            success: function (res) {
                // 返回结果处理
                if (res.code == 0) {
                    return layer.msg(res.msg, { icon: 1, time: 900 },function(){
                        back();
                    });
                } else {
                    return layer.msg(res.msg, { icon: 2, time: 900 });
                }
            }
        });

    }

    // 返回按钮
    function back() {
        // 获取到父级容器
        var index = parent.layer.getFrameIndex(window.name);
        // 关闭父级容器
        parent.layer.close(index);
    }

</script>